package com.bf.electroplating.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bf.electroplating.pojo.dto.IdDTO;
import com.bf.electroplating.pojo.dto.inspection.InspectionFeedbackDTO;
import com.bf.electroplating.pojo.vo.ResultVO;
import com.bf.electroplating.pojo.vo.inspection.InspectionFeedbackVO;
import com.bf.electroplating.service.InspectionFeedbackService;
import com.bf.electroplating.util.idempotent.Idempotent;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/inspection-feedback")
@Tag(name = "巡检反馈", description = "巡检反馈管理")
public class InspectionFeedbackController {

    @Resource
    private InspectionFeedbackService inspectionFeedbackService;

    @PostMapping("/list")
    @Operation(summary = "获取巡检反馈列表", description = "分页获取巡检反馈列表信息")
    public ResultVO<Page<InspectionFeedbackVO>> getFeedbackList(@RequestBody InspectionFeedbackDTO dto) {
        return ResultVO.ok(inspectionFeedbackService.getFeedbackList(dto, false));
    }

    @PostMapping("/resultList")
    @Operation(summary = "获取巡检反馈结果列表", description = "获取巡检反馈结果列表")
    public ResultVO<Page<InspectionFeedbackVO>> getFeedbackResultList(@RequestBody InspectionFeedbackDTO dto) {
        return ResultVO.ok(inspectionFeedbackService.getFeedbackList(dto, true));
    }

    @PostMapping("/getFeedbackById")
    @Operation(summary = "获取巡检反馈详情", description = "根据ID获取巡检反馈详细信息")
    public ResultVO<InspectionFeedbackVO> getFeedbackById(@RequestBody IdDTO id) {
        return ResultVO.ok(inspectionFeedbackService.getFeedbackById(id.getId()));
    }

    @Idempotent
    @PostMapping("/updateFeedback")
    @Operation(summary = "修改巡检反馈", description = "修改巡检反馈信息")
    public ResultVO<Boolean> updateFeedback(@RequestBody InspectionFeedbackVO vo) {
        return ResultVO.ok(inspectionFeedbackService.updateFeedback(vo), "保存成功");
    }
} 